/**
 * @author zulianp@lu.unisi.ch & remo.lemma@lu.unisi.ch
 */

package ch.unisi.inf.projects.java.uom.gui.commands;

import java.awt.event.ActionEvent;
import java.util.Set;
import ch.unisi.inf.projects.java.uom.elements.*;

public final class ItemDeleteCommand extends Command {
	
	/** We are not going to serialize this class atm */
	private static final long serialVersionUID = -1L;
	
	final Set<Element> elements;
	
	public ItemDeleteCommand (final Set<Element> elements)
	{
		super();
		this.elements = elements;
        putValue(NAME,"Delete Item");
        putValue(SHORT_DESCRIPTION,"Deletes an item");
		//edit = new ElementDeleteEdit(elements);
	}
    
    public void actionPerformed(final ActionEvent ev)
    {  
    	for (final Element el : elements) {
    		try {
    			ItemManager.instance().elementDelete(el);
    		}
    		catch (final Exception ex)
    		{
    			ex.printStackTrace();
    			assert false;
    		}
    	}
    	fireActionPerformed();
    }
}
